﻿$(document).ready(function(){

	$("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
	
	$("ul.topnav li span").click(function() { //When trigger is clicked...
		
		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click

		$(this).parent().hover(function() {
		}, function(){	
			//$(this).parent().find("ul.subnav").slideUp('fast'); //When the mouse hovers out of the subnav, move it back up
		});
		$(document).bind("click",function(e){
			$(".subnav ").hide();
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() { 
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});

});


	  X.cartOut = function(){}
	  X.cartIn = function(){var _cart_x = jQuery('#cart_info').offset().left;jQuery('#buy_listly').css({'left':_cart_x - 67});}
	  X.goCart = function(){window.location.href =  WEB_ROOT+"/order-shoppingcart";}
	  jQuery(document).ready(function(){
		jQuery('#cart_info').hover(function(){
				X.cartIn();///淡入
				jQuery('#buy_listly').stop().fadeIn('slow').css({'display':'block','opacity':1});
				
		},function(){
				jQuery('#buy_listly').fadeOut('fast');
				jQuery('#buy_listly').hover(function(){
						X.cartIn();
						jQuery(this).stop().fadeIn('slow').css({'display':'block','opacity':1});
					},function(){
						//X.cartOut();
						
						jQuery('#buy_listly').stop().fadeOut('fast');
						X.cartOut();
					});
				
		});
		jQuery('#buy_listly').hover(function(){},function(){jQuery('#buy_listly').stop().fadeOut('fast');X.cartOut();});
		
		///end ready
		});
	  
function connumber(){
	var brandname = jQuery('#countries').val();
	var number = jQuery('#number').val();
	number = encodeURIComponent(number);
	var bid = jQuery('#countriesid').val();
	if(!brandname || !number){
		alert("品牌和批号不能为空");
		return false;
	}else{
		X.get(WEB_ROOT + '/ajax/pihao.php?bid='+bid+'&brandname='+brandname+'&number='+number);
	}
};
function catnumber(){
	var brandname = jQuery('#countries').val();
	var number = jQuery('#number').val();
	number = encodeURIComponent(number);
	var bid = jQuery('#countriesid').val();
	var area = jQuery('#area').val();
	if(!brandname || !number){
		alert("品牌和批号不能为空");
		return false;
	}else{
		X.get(WEB_ROOT + '/ajax/pihao.php?bid='+bid+'&brandname='+brandname+'&number='+number+'&area='+area);
	}
};
function brandnumber(){
	var number = jQuery('#number').val();
	number = encodeURIComponent(number);
	var bid = jQuery('#countriesid').val();
	if(!number||number=="请输入要查询的批号"){
		alert("批号不能为空");
		return false;
	}else{
		X.get(WEB_ROOT + '/ajax/pihao.php?bid='+bid+'&number='+number);	
		//jQuery('#form1').ajaxSubmit(options);
	}
};
